package Socket.UDP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class Receive {

    public static void main(String... args) throws Exception {
        DatagramSocket socket = new DatagramSocket(8888);
        while (true) {
            DatagramPacket packet = new DatagramPacket(new byte[1024], 1024);
            socket.receive(packet);
            System.out.println(packet.getAddress().getHostAddress() + ":" + packet.getPort() + "->"
                    + new String(packet.getData(), 0, packet.getLength()));
        }
    }

}
